//package com.choosefine.base.shixiaobao.test.controller;
//
//import java.io.IOException;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.choosefine.base.shixiaobao.base.BaseController;
//import com.choosefine.base.shixiaobao.common.def.ResultCode;
//import com.choosefine.base.shixiaobao.common.utils.MapUtil;
//import com.choosefine.base.shixiaobao.listener.AttendanceListener;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//import Com.FirstSolver.Splash.FaceId;
//import Com.FirstSolver.Splash.FaceIdAnswer;
//import Com.FirstSolver.Splash.FaceId_ErrorCode;
//import Com.FirstSolver.Splash.FaceId_Item;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiResponse;
//import io.swagger.annotations.ApiResponses;
//
///**
// * Created by Administrator on 2017/5/12 0012.
// */
//@RestController
//@RequestMapping("/attendance")
//@Api(value = "考勤相关", description = "顾文伟")
//public class AttendanceController extends BaseController{
//
//    @Autowired
//    ObjectMapper jsonObjectMapper;
//
//    /** 汉王IP地址 **/
//    @Value("#{yaml.get('hanwang.client.host')}")
//    private String		hanwanghost		= null;
//
//    /** 汉王端口号 **/
//    @Value("#{yaml.get('hanwang.client.port')}")
//    private String		hanwangport		= null;
//
//    /** 未登录状态变更密码 **/
//    @Value("#{yaml.get('hanwang.client.password')}")
//    private String		hanwangpassword	= null;
//
//    /** 服务器IP地址 **/
//    @Value("#{yaml.get('hanwang.server.host')}")
//    private String		serverhost		= null;
//
//    /** 服务器端口号 **/
//    @Value("#{yaml.get('hanwang.server.port')}")
//    private String		serverport		= null;
//
//    @ApiOperation(value = "获取考勤机数据", notes = "")
//    @ApiResponses({ @ApiResponse(code = ResultCode.SUCCESS, message = ResultCode.MSG_SUCCESS),
//            @ApiResponse(code = ResultCode.FAILED, message = ResultCode.MSG_PARAMS_NULL) })
//    @GetMapping("/machineinfo")
//    public String getMachineInfo() {
//        String result = null;
//        try(FaceId tcpClient = new FaceId(hanwanghost,Integer.parseInt(hanwangport))){
//            tcpClient.setSecretKey(hanwangpassword);
//            FaceIdAnswer output = new FaceIdAnswer();
//            FaceId_ErrorCode ErrorCode = tcpClient.Execute("GetDeviceInfo()", output, "UTF-8");
//            FaceId_Item[] faceId_item = FaceId_Item.GetAllItems(output.answer);
//            MapUtil.faceItemChangeMap(faceId_item);
//            if (ErrorCode.equals(FaceId_ErrorCode.Success))
//            {
//              result = output.answer;
//            }
//        } catch (RuntimeException|IOException e) {
//            e.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return result;
//    }
//
//    @ApiOperation(value = "开启服务器监听", notes = "")
//    @ApiResponses({ @ApiResponse(code = ResultCode.SUCCESS, message = ResultCode.MSG_SUCCESS),
//            @ApiResponse(code = ResultCode.FAILED, message = ResultCode.MSG_PARAMS_NULL) })
//    @GetMapping("/startListener")
//    public String startAttendanceListener() throws Exception {
//        String result = null;
//        AttendanceListener attendanceListener = new AttendanceListener(serverhost,serverport);
//        if(attendanceListener.isServerRunning()){
//            result = responseSuccess(null,"监听创建成功");
//        }else{
//            result = responseFail("监听创建失败");
//        }
//        return result;
//    }
//
//}
